<?php
/**
 * User: i@fedax.cn
 * Time: 2018/7/26 14:33
 */

namespace app\admin\model;


class AliPay extends DataBase
{
    protected $name = 'withdrawal_info';
    protected $autoWriteTimestamp = true;
    protected $updateTime = 'create_time';
    public function getUpdateTimeAttr($value)
    {
        return date('Y-m-d', $value);
    }

    public function getAddTimeAttr($value)
    {
        return date('Y-m-d H:i:s', $value);
    }

    /**
     * @param $page_config
     * @param $where
     * @param $order
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getDataList($page_config, $where, $order)
    {
        $data =  $this
            ->view('Users', 'u_number as u_id')
            ->view('withdrawalInfo', 'id,alipay_card,alipay_name,phone,identity_card,bank,bank_branch,bank_number,created_at as add_time', 'withdrawalInfo.user_id=Users.user_id')
            ->where($where)
            ->order($order)
            ->paginate($page_config);

        foreach($data as $key => $value){

            $data[$key]['bank'] = $value['bank'] ? $value['bank'] : '暂未绑定';
            $data[$key]['bank_branch'] = $value['bank_branch'] ? $value['bank_branch'] : '暂未绑定';
            $data[$key]['bank_number'] = $value['bank_number'] ? $value['bank_number'] : '暂未绑定';
        }

        return $data;
    }

}